package com.example.role_based_permission_control.api;

import com.example.role_based_permission_control.entity.dto.Menu;
import com.example.role_based_permission_control.service.IMenuService;
import com.example.role_based_permission_control.util.CustomResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 李云龙
 * @program: role_based_permmsion_control
 * @description:
 * @date 2024-09-01 16:28:39
 */
@RestController
public class MenuController {
    @Autowired
    private IMenuService menuService;

    @GetMapping("/menus/{userId}")
    public ResponseEntity<CustomResponse> getUserMenus(@PathVariable int userId) {
        List<Menu> menuList = menuService.getUserMenus(userId);
        CustomResponse response = new CustomResponse(200, "menu list!", menuList);
        return ResponseEntity.ok(response);
    }
}